package com.windowes.weichang.controller.manage;

import com.windowes.weichang.access.AccessLimit;
import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.pojo.Message;
import com.windowes.weichang.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/6/2 下午9:01
 * @description:
 *
 **/
@Api(description = "消息相关API")
@RestController
@RequestMapping("message")
public class MessageController {

    @Autowired
    MessageService issueService;

    @ApiOperation(value = "添加/更新", notes = "")
    @PostMapping("addOrUpdate")
    public ServerResponse addOrUpdate(@RequestBody Message issue) {
        return issueService.addOrUpdate(issue);
    }

    @AccessLimit
    @ApiOperation(value = "消息列表", notes = "")
    @GetMapping("list")
    public ServerResponse list(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                               @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        return issueService.list(pageNo, pageSize);
    }

    @ApiOperation(value = "删除消息", notes = "")
    @PostMapping("delete")
    public ServerResponse delete(Integer id) {
        return issueService.delete(id);
    }


}
